/**
* This file is part of tictionary.
*
* tictionary is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with dev.clipall.  If not, see <http://www.gnu.org/licenses/>.
*
* http://code.google.com/p/tictionary/
*/

/*
 * Letter.java
 * Created on January 20, 2008, 10:51 AM
 */

package dicterator.dict;


/**
 *
 * @author Erol Hira
 */
public class Letter {
    
    private char letter; // used in internal computation, finally chars used.
    private String chars; // finally used instead of letter.
    
    private LetterSet selfSet;
    private LetterSet childSet;
    
    private String mean;
    
    
    //----------------------------------------------------------------------
    
    private int childSetOffset;
    private int selfSetOffset;
    private int meanOffset = -1; // if mean == null then meanOffset = -1
    
    //----------------------------------------------------------------------
    
    public Letter(char letter, LetterSet selfSet) {
        this.letter = letter;
        this.selfSet = selfSet;        
    }
    
    //----------------------------------------------------------------------         
    
    public LetterSet forcedGiveChildSet(){
        if(childSet == null){
            childSet = new LetterSet(this);            
        }
        
        return childSet;
    }
    
    public LetterSet getChildSet(){
        return childSet;
    }
    
    public void setNoChildSet(){
        childSet = null;
    }
    
    //----------------------------------------------------------------------
    
    @Override
    public int hashCode() {
        return letter;
    }

    @Override
    public boolean equals(Object obj) {
        return hashCode() == obj.hashCode();
    }    
    
    //----------------------------------------------------------------------
    
    public char getLetter() {
        return letter;
    }   

    public LetterSet getSelfSet() {
        return selfSet;
    }      

    public String getMean() {
        return mean;
    }

    public void setMean(String mean) {
        this.mean = mean;
    }

    public int getChildSetOffset() {
        return childSetOffset;
    }

    public void setChildSetOffset(int childSetOffset) {
        this.childSetOffset = childSetOffset;
    }

    public int getMeanOffset() {
        return meanOffset;
    }

    public void setMeanOffset(int meanOffset) {
        this.meanOffset = meanOffset;
    }

    public int getSelfSetOffset() {
        return selfSetOffset;
    }

    public void setSelfSetOffset(int selfSetOffset) {
        this.selfSetOffset = selfSetOffset;
    }

    public String getChars() {
        return chars;
    }

    public void setChars(String chars) {
        this.chars = chars;
    }
    
}
